#!/bin/sh
# Get the image, putting in the rigth place and mount it

PREREQ="local"

prereqs()
{
	echo "$PREREQ"
}

case $1 in
# get pre-requisites
prereqs)
	prereqs
	exit 0
	;;
esac

# Just to be sure
modprobe -q squashfs >> /tmp/initramfs.debug 2>&1
modprobe -q loop >> /tmp/initramfs.debug 2>&1

IMAGE=/mnt/image
mkdir -p ${IMAGE} >> /tmp/initramfs.debug 2>&1

mknod /dev/loop0 b 7 0 >> /tmp/initramfs.debug 2>&1

test="${dirconf}"

if [ "x$test" = "xram" ]; then

mount -o loop -t squashfs /mnt/ram/*.squashfs $IMAGE >> /tmp/initramfs.debug 2>&1

else

mount -o loop -t squashfs /mnt/dev/*.squashfs $IMAGE >> /tmp/initramfs.debug 2>&1

fi

if [ $? = 0 ]; then
	echo "SETUP_IMAGE: image mounted"  >> /tmp/initramfs.debug 2>&1

	exit 0
else
	echo "SETUP_IMAGE: ERROR -> image non mounted"  >> /tmp/initramfs.debug 2>&1
	exit 1
fi
